﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using Icst.Leaflike.Logging;
using Icst.Leaflike.Discuz;


namespace Icst.Leaflike.Web
{
    public abstract class masterpagebase : MasterPage
    {
        public string RequestUrl
        {
            get
            {
                string pathAndQuery = Request.Url.PathAndQuery;
                if (pathAndQuery.Contains("login") ||
                    pathAndQuery.Contains("register"))
                {
                    pathAndQuery = "index.aspx";
                }
                return pathAndQuery.TrimStart('/').Replace(".aspx", ".htm");
            }
        }
        public bool IsLogon { get { return UserAccount.IsLogon(); } }
        public string UserName { get { return UserAccount.UserName(); } }
        public long UserId { get { return UserAccount.UserId(); } }
        public string ForumAdminSite { get { return AppConfig.forum_admin; } }
        protected Version Version { get { return Session.getVersion(AppConfig.cookiedomain); } }
        public string CurrentVersion
        {
            get
            {
                switch (Version)
                {
                    case Version.Professional: return "专业版";
                    case Version.Public: return "大众版";
                    default: return "";
                }
            }
        }

        protected void Page_Error(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError();
            Logger.Error("master page error:" + ex.Message);
        }
    }
}
